/*
package com.xncoding.freemarker.service;

import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.export.ExcelExportService;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xncoding.freemarker.utile.RegexUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

@Service
public class SwServiceImpl {


    public void getSw() throws IOException {
//        String s = HttpUtil.get("http://10.3.20.61:18191/ebank/actuator/eos/v2/api-docs");
//        String s = HttpUtil.get("http://10.3.20.61:18291/mbank/actuator/eos/v2/api-docs");
//        String s = HttpUtil.get("http://127.0.0.1:18191/ebank/actuator/eos/v2/api-docs");
        //1、生成一个jedis对象，这个对象负责和指定Redis节点进行通信
        Jedis jedis = new Jedis("localhost", 6379);
        //带密码需要执行认证方法，这里我的Redis没有设密码就不用管
        //jedis.auth("123456");

        //2、jedis存入数据
        jedis.set("hello", "world");
        //3、jedis获取数据
        String value = jedis.get("hello");


        String s = HttpUtil.get("http://127.0.0.1:8080/swagger-ui.html");
        JSONObject jsonObject = JSONObject.parseObject(s);
        JSONObject paths = jsonObject.getJSONObject("paths");
        JSONObject definitions = jsonObject.getJSONObject("definitions");

        List<Map<String, String>> list = new ArrayList<>();

        List<Map<String, Object>> allList = new ArrayList<>();

        paths.keySet().stream().forEach(x -> {
            System.err.println("接口地址====" + x);
            System.err.println("功能名称====" + paths.getJSONObject(x).getJSONObject("post").getJSONArray("tags").get(0).toString());
            System.err.println("接口名称====" + paths.getJSONObject(x).getJSONObject("post").getString("summary"));

            Map<String, String> h1 = new HashMap<String,String>();

            h1.put("jkdz", x);
            h1.put("jkmc", paths.getJSONObject(x).getJSONObject("post").getString("summary"));
            h1.put("mnmc", paths.getJSONObject(x).getJSONObject("post").getJSONArray("tags").get(0).toString());
            h1.put("fum", RegexUtils.humpToLowerLine(x.replace("/",""),true));
            String jkdz[] =x.split("/");
            String ljgjb = jkdz.length == 2? jkdz[0]:jkdz[1];
            h1.put("ljgjb", RegexUtils.humpToLowerLine(ljgjb,true));
            h1.put("ljgjm", ljgjb);
            h1.put("ywljm", jkdz[jkdz.length-1]);

            list.add(h1);
//            allList.add((Map<String, Object>) list);

        });

        List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();//构造对象等同于@Excel

        entity.add(new ExcelExportEntity("一级分类", "mnmc"));
        entity.add(new ExcelExportEntity("交易名称", "jkmc"));
        entity.add(new ExcelExportEntity("请求路径", "jkdz"));
        entity.add(new ExcelExportEntity("服务码", "fum"));
        entity.add(new ExcelExportEntity("逻辑构建包", "ljgjb"));
        entity.add(new ExcelExportEntity("逻辑构建名", "ljgjm"));
        entity.add(new ExcelExportEntity("业务逻辑名", "ywljm"));

//        ExcelExportUtil.exportExcel(new ExportParams("测试11", "测试22"), entity, allList);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entity, list);
        FileOutputStream fos = new FileOutputStream("D:/home/excel01/ExcelExportForMap03.xls");
        workbook.write(fos);
        fos.close();
    }


    public void getSw04() throws Exception {
//        String s = HttpUtil.get("http://10.3.20.61:18191/ebank/actuator/eos/v2/api-docs");
        String s = HttpUtil.get("http://127.0.0.1:18191/ebank/actuator/eos/v2/api-docs");
        JSONObject jsonObject = JSONObject.parseObject(s);
        JSONObject paths = jsonObject.getJSONObject("paths");
        JSONObject definitions = jsonObject.getJSONObject("definitions");
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String>[] h1 = new Map[]{null};

        List<Map<String, Object>> allList = new ArrayList<>();


        // 将sheet1、sheet2使用得map进行包装
        List<Map<String, Object>> sheetsList = new ArrayList<>();

        List<ExcelExportEntity> filedEntity = new ArrayList<ExcelExportEntity>();//构造对象等同于@Excel
        filedEntity.add(new ExcelExportEntity("字段名称", "zdmc"));
        filedEntity.add(new ExcelExportEntity("字段类型", "zdlx"));
        filedEntity.add(new ExcelExportEntity("字段中文名称", "zdzwmc"));


        Map<Integer, List<Map<String, Object>>> map=new HashMap<>();
        AtomicInteger i = new AtomicInteger(0);
//        final int[] i = {0};
        //入参
        paths.keySet().stream().forEach(x -> {
            String jkmc = paths.getJSONObject(x).getJSONObject("post").getString("summary");
            String jkdz = x;
            System.err.println("接口地址====" + jkdz);
            System.err.println("功能名称====" + paths.getJSONObject(x).getJSONObject("post").getJSONArray("tags").get(0).toString());
            System.err.println("接口名称====" + paths.getJSONObject(x).getJSONObject("post").getString("summary"));
            List<Map<String, Object>> filelistcp = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> mList1cp=new ArrayList<>();

//            Optional<JSONObject> RES =  Optional.ofNullable(paths.getJSONObject(x).getJSONObject("post").getJSONObject("responses"));
            Optional.ofNullable(paths.getJSONObject(x).getJSONObject("post").getJSONArray("parameters"))
                    .ifPresent(y -> {

                        JSONObject a = (JSONObject) y.get(0);

                        Optional.ofNullable(a.getJSONObject("schema")).ifPresent(z -> {
                            Optional<String> name = Optional.ofNullable(z.getString("$ref"));
                            if(name.isPresent()){
                                Optional<JSONObject> param = Optional.ofNullable(definitions.getJSONObject(z.getString("$ref").replaceAll("#/definitions/","")));
                                if(param.isPresent()){
                                    List<Map<String, Object>> filelist = new ArrayList<Map<String, Object>>();
                                    List<Map<String, Object>> mList1=new ArrayList<>();
                                    Optional.ofNullable(param.get().getJSONObject("properties")).ifPresent(c -> {
                                        System.err.println("入参开始@@@@@@@@@@@@@@@@@");
//                                        filelist.add(mcMap);
                                        c.keySet().stream().forEach(v -> {
                                            Map<String, Object> fiedMap = new HashMap<>();
                                            System.err.println("入参字段名称======" + v);
                                            System.err.println("入参字段类型======" + c.getJSONObject(v).getString("type"));
                                            System.err.println("入参字段中文名称======" + c.getJSONObject(v).getString("description"));
                                            if ("localHead".equals(v) || "uri".equals(v) ||"sysHead".equals(v)){
                                                return;
                                            }
                                            fiedMap.put("zdmc",v==null?"":v);
                                            String zdlx = c.getJSONObject(v).getString("type");
                                            String zdzwmc = c.getJSONObject(v).getString("description");
                                            fiedMap.put("zdlx",zdlx ==null?"":zdlx);
                                            fiedMap.put("zdzwmc",zdzwmc==null?"":zdzwmc);
                                            fiedMap.put("kong","");
                                            filelist.add(fiedMap);
                                        });

                                    });

                                    Map<String, Object> data = new HashMap<String, Object>();
                                    data.put("inlist",filelist);
                                    //出参
                                    output(paths,definitions, x, data);
                                    data.put("jkmc",jkmc);

                                    data.put("jkdz",jkdz);
                                    String[] fwff = jkdz.split("/");
                                    data.put("fwff",fwff[fwff.length-1]);
                                    data.put("fwbh", RegexUtils.humpToLowerLine(jkdz.replace("/",""),true));
                                    // 设置sheetName，若不设置该参数，则使用得原本的sheet名称
                                    data.put("sheetName",jkmc.replace("/",""));
                                    mList1.add(data);
                                    System.err.println(filelist.toString());
                                     map.put(i.getAndIncrement(),mList1);

                                }

                            }
                        });
                    });


        });


        TemplateExportParams params = new TemplateExportParams("doc/20230713.xls");
//        Workbook workbook = ExcelExportUtil.exportExcel(params, data);
        System.err.println(JSON.toJSONString(map));
        Workbook workbook = ExcelExportUtil.exportExcelClone(map, params);
//        Workbook workbook = ExcelExportUtil.exportExcel(map, params);
        File savefile = new File("D:/home/excel01/");
        if (!savefile.exists()) {
            savefile.mkdirs();
        }
        FileOutputStream fos = null;
            fos = new FileOutputStream("D:/home/excel01/040201.xls");
            workbook.write(fos);
            fos.close();
    }

    public void  output(JSONObject paths,JSONObject definitions,String x,Map<String, Object> data){

        //出参
        Optional.ofNullable(paths.getJSONObject(x).getJSONObject("post").getJSONObject("responses"))
                .ifPresent(y -> {
                    JSONObject a = (JSONObject) y.get("200");
                    Optional.ofNullable(a.getJSONObject("schema")).ifPresent(z -> {
                        Optional<String> name = Optional.ofNullable(z.getString("$ref"));
                        if(name.isPresent()){
                            Optional<JSONObject> param = Optional.ofNullable(definitions.getJSONObject(z.getString("$ref").replaceAll("#/definitions/","")));
                            if(param.isPresent()){
                                List<Map<String, Object>> filelist = new ArrayList<Map<String, Object>>();
                                List<Map<String, Object>> mList1=new ArrayList<>();

                                Optional.ofNullable(param.get().getJSONObject("properties")).ifPresent(c -> {
                                    System.err.println("入参开始@@@@@@@@@@@@@@@@@");
                                    c.keySet().stream().forEach(v -> {
                                        System.err.println("出参字段名称======" + v);
                                        System.err.println("出参字段类型======" + c.getJSONObject(v).getString("type"));
                                        System.err.println("出参字段中文名称======" + c.getJSONObject(v).getString("description"));
                                        if ("localHead".equals(v) || "uri".equals(v) ||"sysHead".equals(v)){
                                            return;
                                        }
                                        Map<String, Object> fiedMap = new HashMap<>();
                                        System.err.println("入参字段名称======" + v);
                                        System.err.println("入参字段类型======" + c.getJSONObject(v).getString("type"));
                                        System.err.println("入参字段中文名称======" + c.getJSONObject(v).getString("description"));
                                        fiedMap.put("zdmc",v==null?"":v);
                                        String zdlx = c.getJSONObject(v).getString("type");
                                        String zdzwmc = c.getJSONObject(v).getString("description");
                                        fiedMap.put("zdlx",zdlx ==null?"":zdlx);
                                        fiedMap.put("zdzwmc",zdzwmc==null?"":zdzwmc);
                                        fiedMap.put("kong","");
                                        filelist.add(fiedMap);
                                    });
                                });
                                data.put("outlist",filelist);
                            }
                        }
                    });
                });
    }

}
*/
